package com.bjesc_b2c.app.appraiset.adapter;

import android.content.Context;
import android.view.View;

import com.bjesc_b2c.app.appraiset.R;
import com.bjesc_b2c.app.appraiset.bean.DealerCarBean;

import java.util.List;

import app.pinggushi.bjesc.com.baserecyclerview.adapter.CommonAdapter;
import app.pinggushi.bjesc.com.baserecyclerview.adapter.base.ViewHolder;


/**
 * Created by yidong on 2017/7/28.
 */

public class XDdataAdapter extends CommonAdapter<DealerCarBean.ListBean> {
    private statusListener statusListener;
    public XDdataAdapter(Context context, int layoutId, List<DealerCarBean.ListBean> datas) {
        super(context, layoutId, datas);
    }
    public void setSListener(statusListener statusListener) {
        this.statusListener = statusListener;
    }
    @Override
    protected void convertView(ViewHolder holder, DealerCarBean.ListBean listBean, final int position) {
        holder.setFrescoUrl(R.id.tv_car_photo,getDatas().get(position).getImg_url(),false);
        holder.setText(R.id.tv_car_type, "车型:  "+getDatas().get(position).getCar_name());
        holder.setText(R.id.tv_car_price, "价格:  "+getDatas().get(position).getOwner_price());
        holder.setText(R.id.tv_car_vin, "VIN码:  "+getDatas().get(position).getVin_number());
        holder.setText(R.id.tv_car_time,"提交时间:  "+ getDatas().get(position).getExamines_time());
        holder.setOnClickListener(R.id.tv_adjustment_status, new View.OnClickListener() {//调价
            @Override
            public void onClick(View v) {
                if (statusListener != null) {
                    statusListener.adjustment(position);
                }
            }
        });
        holder.setOnClickListener(R.id.tv_unusual, new View.OnClickListener() {//下架
            @Override
            public void onClick(View v) {
                if (statusListener != null) {
                    statusListener.unusual(position);
                }
            }
        });
        holder.setOnClickListener(R.id.tv_off_status, new View.OnClickListener() {//下架
            @Override
            public void onClick(View v) {
                if (statusListener != null) {
                    statusListener.offShelf(position);
                }
            }
        });
    }
    public interface statusListener {
        void adjustment(int position);
        void offShelf(int position);
        void unusual(int position);
    }
}
